package org.example.function_interface.Supplier;

import java.util.Random;
import java.util.function.Supplier;

public class SupplierWithMethodReference {
    public static void main(String[] args) {
        Supplier<String> s1 = MyUtil::getFavoriteBook;
        System.out.println(s1.get());
        MyUtil myUtil = new MyUtil();
        Supplier<Integer> s2 = myUtil::getAge;
        System.out.println(s2.get());

        Random random = new Random();
        Supplier<Integer> s3 = random::nextInt;
        System.out.println(s3.get());
    }
}

class MyUtil {
    private final Integer age = 30;
    public static String getFavoriteBook(){
        return "Mahabharat";
    }
    public Integer getAge(){
        return age;
    }
}
/* 输出
Mahabharat
30
-682408931
*/
